package Exercise;
//打乱字符串的内容
import java.util.Scanner;
import java.util.Random;
public class Stirng_9 {
    public static void main(String[] args) {
        //键盘录入
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符串：");
        String sr = sc.next();
       //输出
        System.out.println(Work(sr));
    }
    //调整
    public static String Work(String sr){
        //产生随机索引
        Random rd = new Random();
        char[] cr = new char[sr.length()];
        cr = sr.toCharArray();
        for (int i = 0; i < cr.length; i++) {
            int flag = rd.nextInt(sr.length());
            char c ;  //临时存放
            //交换打乱内容
            c = cr[flag];
            cr[flag] = cr[i] ;
            cr[i] = c;
        }
        String newstr = new String(cr);
        return newstr;
    }
}
